package Java多线程和并发.final详解;

import java.math.BigInteger;
import java.util.Arrays;

/**
 * @program: algorithm
 * @description:
 * @author: 陈恩涛
 * @create: 2022-03-29 21:08
 **/
public class OneValueCache {

    private final BigInteger lastNumer;
    private final BigInteger[] lastFactors;

    public OneValueCache(BigInteger lastNumer, BigInteger[] lastFactors) {
        this.lastNumer = lastNumer;
        this.lastFactors = Arrays.copyOf(lastFactors, lastFactors.length);
    }

    public BigInteger[] getLastFactors(BigInteger i) {
        if (lastFactors == null || !lastNumer.equals(i)) {
            return null;
        } else {
            return Arrays.copyOf(lastFactors, lastFactors.length);
        }
    }

    public static void main(String[] args) {
        BigInteger a = new BigInteger("123");
        BigInteger[] bigIntegers = new BigInteger[1];
        bigIntegers[0] = a;
        OneValueCache oneValueCache = new OneValueCache(a, bigIntegers);
    }
}
